Remove no-op failOnError argument from DeleteEntityDataFetcher#15692
Conversation
GORM's delete(Map) only honors the flush parameter, so the failOnError: true argument passed in deleteInstance() was silently ignored. Switch to delete(flush: true) so the delete executes immediately and any failure surfaces through the data fetcher's response handler. Flagged during review of #15599. Assisted-by: claude-code:claude-4.8-opus
There was a problem hiding this comment.
Pull request overview
This pull request fixes DeleteEntityDataFetcher.deleteInstance() to use a GORM delete option that is actually honored, ensuring delete failures surface immediately and are handled by the existing try/catch response creation logic.
Changes:
- Updated
DeleteEntityDataFetcher.deleteInstance()fromdelete(failOnError: true)todelete(flush: true)so the delete is executed/flushed immediately. - Added a Spock interaction test to assert the fetcher calls
delete(flush: true)and does not pass the ignoredfailOnErrorargument.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| grails-data-graphql/core/src/main/groovy/org/grails/gorm/graphql/fetcher/impl/DeleteEntityDataFetcher.groovy | Uses flush: true for deletes so failures surface at the delete point and can be captured by existing error handling. |
| grails-data-graphql/core/src/test/groovy/org/grails/gorm/graphql/fetcher/impl/DeleteEntityDataFetcherSpec.groovy | Adds an interaction test locking in the delete(flush: true) call and preventing regression to the ignored failOnError argument. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
I had no idea that delete doesn't honor failOnError. Seems like a gap in the API. It makes sense to remove the failOnError, but forcing a flush may have unexpected behavior. Why are you flushing by default now? Wouldn't it be better to let the transaction finish and let the transaction manager flush instead?
|
|
||
| then: 'the delete is flushed so database failures surface, and failOnError (ignored by delete) is not used' | ||
| 1 * instance.delete([flush: true]) | ||
| 0 * instance.delete([failOnError: true]) |
There was a problem hiding this comment.
Mock tests generally are fragile since we're not actually testing the result. Shouldn't we instead check the persisted state?
|
The test in question uses a mock to verify that the grails-data-graphql/core/src/test/groovy/org/grails/gorm/graphql/fetcher/impl/DeleteEntityDataFetcherSpec.groovy |
GORM's delete(Map) only honors the flush key, so the failOnError: true argument passed in deleteInstance() was silently ignored - the call behaved as a plain non-flushing delete(). Switching to delete(flush: true) would force an immediate flush and therefore change runtime behavior. Instead call instance.delete() with no arguments, preserving the original behavior exactly while removing the misleading failOnError argument that did nothing. Flagged during review of #15599. Assisted-by: claude-code:claude-4.8-opus
|
Updated this PR to avoid changing any behavior. The previous revision switched the call to The latest commit instead changes the call to a plain
In short: this is now a pure no-op cleanup that drops a dead parameter, not a behavior change. The interaction test was updated to assert |
✅ All tests passed ✅🏷️ Commit: 0f4fe69 Learn more about TestLens at testlens.app. |
Summary
DeleteEntityDataFetcher.deleteInstance()calledinstance.delete(failOnError: true), but GORM'sdelete(Map)only honors theflushkey - thefailOnErrorargument is silently ignored. The call therefore already behaved as a plain, non-flushingdelete(). ThefailOnErrorargument gave a false impression of doing something when it did nothing.This removes that misleading argument by switching to a plain
instance.delete(). Behavior is unchanged: the delete still executes without forcing a flush, exactly as before. This is a pure cleanup with no functional change - it just drops a parameter that was a no-op.Changes
DeleteEntityDataFetcher:delete(failOnError: true)todelete().DeleteEntityDataFetcherSpec: updated the interaction test to assertdeleteInstancecallsdelete()with no arguments and never passes the ignoredfailOnErrorargument.Testing
All pass, including the existing happy-path / invalid-id cases and the
SoftDeleteEntityDataFetcher(which overridesdeleteInstance) regression check.Flagged during review of #15599.